import { createI18n } from 'vue-i18n'
import enLocale from './en'
import zhLocale from './zh'

// Element Plus locale imports
import enElement from 'element-plus/es/locale/lang/en'
import zhElement from 'element-plus/es/locale/lang/zh-cn'

const messages = {
  en: {
    ...enElement,
    ...enLocale
  },
  zh: {
    ...zhElement,
    ...zhLocale
  }
}

const i18n = createI18n({
  legacy: false, // Vue 3 composition API mode
  locale: localStorage.getItem('locale') || 'en', // Default language
  fallbackLocale: 'en', // Fallback language
  messages,
})

export default i18n